<!--展示了如何使用上传组件和进行必填校验-->
<template>
  <div>
    <fks-form :rules="formRules">
      <fks-form-item prop="attachment">
        <FormUpload
          v-model="formData.attachment"
          @fileChange="fileChange"
        />
      </fks-form-item>
    </fks-form>
  </div>
</template>

<script>
import FormUpload from './index'

export default {
  name: 'Readme',
  components: {FormUpload},
  data() {
    return {
      formData: {
        attachment: '',
        fileCount:0
      }
    }
  },
  computed:{
    formRules(){
      return {
        attachment:[{
          required:true,
          validator:(rule,value,callback)=>{
            if(this.fileCount<=0){
              callback(new Error('请上传文件'))
            }
          }
        }]
      }
    }
  },
  methods:{
    fileChange(file,fileList,fileCount){
      this.fileCount = fileCount
    }
  }
}
</script>

<style scoped>

</style>